﻿<UserControl x:Class="TimeSplicerModule.Views.ProjectView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             Width="800" Height="Auto">


    <Grid Name="layoutGrid" VerticalAlignment="Top" HorizontalAlignment="Left">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="500" />
            <RowDefinition Height="60" />
        </Grid.RowDefinitions>

        <Border Margin="4">
            <controls:MetroAnimatedSingleRowTabControl>
                <TabItem Header="Project Info">
                    <Grid VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0,10,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition Width="225" />
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition Width="225" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition Height="75" />
                        </Grid.RowDefinitions>


                        <!-- Name -->
                        <Border Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                            <TextBlock Text="Name:" />
                        </Border>

                        <Border Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                            <TextBox Text="{Binding Path=Name, Mode=TwoWay}" Width="200" IsEnabled="{Binding Path=IsEnabled}" />
                        </Border>
                        
                        
                        <!-- Project Manager -->
                        <Border Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                            <TextBlock Text="Project Manager:" />
                        </Border>

                        <Border Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                            <ComboBox Name="projectManagerComboBox" ItemsSource="{Binding Path=ProjectManagers}" Width="200" Height="25" 
                                      IsEnabled="{Binding Path=IsEnabled}"
                                      DisplayMemberPath="FullName"
                                      SelectedValuePath="UserGuid"
                                      SelectedValue="{Binding Path=ProjectManagerGuid, UpdateSourceTrigger=PropertyChanged}">
                            </ComboBox>
                        </Border>


                        <!-- Category -->
                        <Border Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                            <TextBlock Text="Category:" />
                        </Border>

                        <Border Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                            <ComboBox Name="categoryComboBox" ItemsSource="{Binding Path=Categories}" Width="200" Height="25"
                                      IsEnabled="{Binding Path=IsEnabled}"
                                      DisplayMemberPath="Name"
                                      SelectedValuePath="CategoryGuid"
                                      SelectedValue="{Binding Path=CategoryGuid, UpdateSourceTrigger=PropertyChanged}">
                            </ComboBox>
                        </Border>


                        <!-- Priority -->
                        <Border Grid.Column="0" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                            <TextBlock Text="Priority:" />
                        </Border>

                        <Border Grid.Column="1" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                            <ComboBox Name="priorityComboBox" ItemsSource="{Binding Path=Priorities}" Width="200" Height="25" 
                                      IsEnabled="{Binding Path=IsEnabled}"
                                      DisplayMemberPath="Name"
                                      SelectedValuePath="PriorityGuid"
                                      SelectedValue="{Binding Path=PriorityGuid, UpdateSourceTrigger=PropertyChanged}">
                            </ComboBox>
                        </Border>

                        <!-- Description  -->
                        <Border Grid.Column="0" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                            <TextBlock Text="Description:" />
                        </Border>

                        <Border Grid.Column="1" Grid.Row="4" Grid.RowSpan="5" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="5">
                            <TextBox Text="{Binding Path=Description, Mode=TwoWay}" Width="200" Height="150" IsEnabled="{Binding Path=IsEnabled}" TextWrapping="Wrap" />
                        </Border>



                        <!-- Status -->
                        <Border Grid.Column="2" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                            <TextBlock Text="Status:" />
                        </Border>

                        <Border Grid.Column="3" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                            <TextBlock Text="{Binding Path=Status.Name}" Width="200" Foreground="{Binding Path=StatusBrushColor, Mode=OneWay}" IsEnabled="{Binding Path=IsEnabled}" />
                        </Border>


                        <!-- Started Date -->
                        <Border Grid.Column="2" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                            <TextBlock Text="Started:" />
                        </Border>

                        <Border Grid.Column="3" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                            <DatePicker  Text="{Binding Path=StartedDate}" Width="200" IsEnabled="{Binding Path=IsEnabled}" />
                        </Border>
                        

                        <!-- Due Date -->
                        <Border Grid.Column="2" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                            <TextBlock Text="Due Date:" />
                        </Border>

                        <Border Grid.Column="3" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                            <DatePicker  Text="{Binding Path=DueDate}" Width="200" IsEnabled="{Binding Path=IsEnabled}" />
                        </Border>


                        <!-- Completed Date -->
                        <Border Grid.Column="2" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5" Visibility="{Binding Path=CompletedDateVisibility}">
                            <TextBlock Text="Completed Date:" />
                        </Border>

                        <Border Grid.Column="3" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5" Visibility="{Binding Path=CompletedDateVisibility}">
                            <DatePicker  Text="{Binding Path=CompletedDate}" Width="200" IsEnabled="False" />
                        </Border>

                        <!-- Estimated Hours -->
                        <Border Grid.Column="2" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                            <TextBlock Text="Estimated Hours:" />
                        </Border>


                        <Border Grid.Column="3" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                            <controls:NumericUpDown Value="{Binding Path=EstimatedHours, Mode=TwoWay}" Minimum="0" Interval="5" Width="75" IsEnabled="{Binding Path=IsEnabled}"  />
                        </Border>
                        
                        
                        <!-- Actual Hours -->
                        <Border Grid.Column="2" Grid.Row="5" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                            <TextBlock Text="Actual Hours:" />
                        </Border>

                        <Border Grid.Column="3" Grid.Row="5" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                            <TextBlock Text="{Binding Path=ActualHours}" />
                        </Border>
                        

                        <!-- Created  -->
                        <Border Grid.Column="2" Grid.Row="6" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                            <TextBlock Text="Created:" />
                        </Border>
                        
                        <Border Grid.Column="3" Grid.Row="6" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                            <TextBlock Text="{Binding Path=CreatedDate}" />
                        </Border>
                        
                        
                        <!-- Created By -->
                        <Border Grid.Column="2" Grid.Row="7" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                            <TextBlock Text="Created By:" />
                        </Border>
                        
                        <Border Grid.Column="3" Grid.Row="7" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                            <TextBlock Text="{Binding Path=CreatedBy.FullName}" />
                        </Border>


                        <!-- Allow Branches, Future -->
                    </Grid>
                </TabItem>
                
                <!-- Project Users -->
                <TabItem Header="Users" Visibility="{Binding Path=UsersVilibility}">
                    <!-- How am i going to set this up -->
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="135" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        
                        <!-- Add User Section -->
                        <Border Grid.Column="0" Grid.Row="0" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="5">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="100" />
                                    <ColumnDefinition Width="225" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                
                                <!-- Users -->
                                <Border Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                                    <TextBlock Text="User:" />
                                </Border>
                                
                                <Border Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                                    <ComboBox Name="usersComboBox" ItemsSource="{Binding Path=Users}" DisplayMemberPath="FullName" SelectedValuePath="UserGuid" Width="200" IsEnabled="{Binding Path=IsEnabled}" />
                                </Border>
                                
                                <!-- Project Roles -->
                                <Border Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                                    <TextBlock Text="Project Role:" />
                                </Border>

                                <Border Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                                    <ComboBox Name="projectRolesComboBox" ItemsSource="{Binding Path=ProjectRoles}" DisplayMemberPath="Name" SelectedValuePath="ProjectRoleGuid" Width="200" IsEnabled="{Binding Path=IsEnabled}" />
                                </Border>

                                <!-- Add Button -->
                                <Border Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                                    <Button Name="addUserButton" Content="Add User" Width="125" Height="25" Click="addUserButton_Click" IsEnabled="{Binding Path=IsEnabled}" />
                                </Border>
                            </Grid>
                        </Border>
                        
                        <!-- Project Users List -->
                        <Border Grid.Column="0" Grid.Row="1" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="5">
                            <DataGrid Name="projectUsersGrid" ItemsSource="{Binding Path=ObservableProjectUsers, Mode=TwoWay}"
                                      AutoGenerateColumns="False"
                                      CanUserAddRows="False"
                                      CanUserDeleteRows="False"
                                      SelectionChanged="projectUsersGrid_SelectionChanged">
                                
                                <DataGrid.Columns>
                                    <DataGridTextColumn Header="Name" Binding="{Binding Path=User.FullName}" />
                                    <DataGridTextColumn Header="Role" Binding="{Binding Path=ProjectRole.Name}" />
                                </DataGrid.Columns>
                            </DataGrid>
                        </Border>
                        
                    </Grid>
                </TabItem>
                
                <!-- Tasks -->
                <TabItem Header="Tasks" Visibility="{Binding Path=TasksVisibility}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="60" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>


                        <Border Grid.Column="0" Grid.Row="0" VerticalAlignment="Top" HorizontalAlignment="Left">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="User:" Margin="25,0,0,0" Height="25" />
                                <ComboBox Name="users1ComboBox" Margin="15,0,0,0" ItemsSource="{Binding Path=ProjectUsers}"
                                          Width="150"
                                          DisplayMemberPath="User.FullName"
                                          SelectedValuePath="UserGuid"
                                          SelectedValue="{Binding Path=SelectedTaskUserGuid, UpdateSourceTrigger=PropertyChanged}"
                                          SelectionChanged="users1ComboBox_SelectionChanged">
                                </ComboBox>

                                <TextBlock Text="Status:" Margin="25,0,0,0" Height="25" />
                                <ComboBox Name="taskStatusesComboBox" ItemsSource="{Binding Path=TaskStatuses}" Margin="15,0,0,0"
                                          Width="150"
                                          DisplayMemberPath="Name"
                                          SelectedValuePath="StatusGuid"
                                          SelectedValue="{Binding Path=SelectedStatusGuid}"
                                          SelectionChanged="taskStatusesComboBox_SelectionChanged">

                                </ComboBox>

                                <TextBlock Text="Search:" Margin="25,0,0,0" Height="25" />
                                <TextBox Name="textSearchTextBox" Text="{Binding Path=SearchText, Mode=TwoWay}" Width="200" Margin="15,0,0,0" Height="25" SelectionChanged="textSearchTextBox_SelectionChanged" />



                            </StackPanel>
                        </Border>

                        <Border Grid.Column="0" Grid.Row="1" Margin="5" VerticalAlignment="Top" HorizontalAlignment="Left">
                            <ListView ItemsSource="{Binding Path=FilteredTasks}"
                                      SelectionChanged="DataGrid_SelectionChanged"
                                      ItemTemplate="{StaticResource ResourceKey=TaskListItemTemplate}">


                                <ListView.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <WrapPanel ItemWidth="400" ItemHeight="65" Width="800" />
                                        <!--<WrapPanel Width="{Binding (FrameworkElement.ActualWidth), 
                                RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}"
                                ItemWidth="{Binding (ListView.View).ItemWidth, 
                                RelativeSource={RelativeSource AncestorType=ListView}}"
                                MinWidth="{Binding ItemWidth, RelativeSource={RelativeSource Self}}"
                                ItemHeight="{Binding (ListView.View).ItemHeight, 
                                RelativeSource={RelativeSource AncestorType=ListView}}" />-->
                                    </ItemsPanelTemplate>
                                </ListView.ItemsPanel>

                                <!--<DataGrid.Columns>
                                    -->
                                <!--<DataGridTextColumn Header="Status" Binding="{Binding Path=Name}"/>
                                    <DataGridTextColumn Header="Description" Binding="{Binding Path=Description}"/>-->
                                <!--
                                </DataGrid.Columns>-->
                            </ListView>
                        </Border>

                    </Grid>
                </TabItem>
                
                <!-- Reports -->
                <TabItem Header="Reports" Visibility="{Binding Path=ReportsVisibility}">
                    <!-- For Right now show complete report only -->
                    <Grid VerticalAlignment="Top" HorizontalAlignment="Left">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        
                        <Border VerticalAlignment="Center" HorizontalAlignment="Left" Margin="25">
                            <Button Name="fullReportButton" Content="Full Report" Width="125" Height="25" Click="fullReportButton_Click" />
                        </Border>
                    </Grid>
                </TabItem>
            </controls:MetroAnimatedSingleRowTabControl>
        </Border>
        
        <!-- Save, Add Task Etc -->
        <Border Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
            <StackPanel Orientation="Horizontal">
                <Button Name="saveButton" Content="Save" Width="100" Height="25" Click="saveButton_Click" IsEnabled="{Binding Path=IsEnabled}" />
                <Button Name="saveExitButton" Content="Save &amp; Exit" Width="100" Click="saveExitButton_Click" Height="25" Margin="15,0,0,0" IsEnabled="{Binding Path=IsEnabled}" />
                <Button Name="cancelButton" Content="Exit" Width="100" Height="25" Click="cancelButton_Click" Margin="15,0,0,0" />
                <Button Name="completeProjectButton" Content="Complete" Width="100" Height="25" Click="completeProjectButton_Click" Margin="15,0,0,0" IsEnabled="{Binding Path=IsCompleteButtonEnabled}" />
                <Button Name="addTask" Content="Add Task" Width="100" Height="25" Click="addTask_Click" Margin="15,0,0,0" Visibility="{Binding Path=TasksVisibility}" IsEnabled="{Binding Path=IsAddTaskButtonEnabled}" />
            </StackPanel>
        </Border>

        <!-- Pregress Ring -->
        <Border Name="progressBorder" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Background="Black"  VerticalAlignment="Center" HorizontalAlignment="Center" Panel.ZIndex="3"
                Width="{Binding ElementName=layoutGrid, Path=ActualWidth}" Height="{Binding ElementName=layoutGrid, Path=ActualHeight}" >
            <controls:ProgressRing Name="progressRing" VerticalAlignment="Center" HorizontalAlignment="Center"  />
        </Border>
    </Grid>
</UserControl>
